<?php

declare(strict_types=1);

namespace App\Model;


/**
 * @property int $id
 * @property int $type 0礼物 1金币 2贵族 3黄金锤 4雷神之锤（3、4只有在砸蛋才用）
 * @property int $gift_id 礼物id
 * @property int $num 数量（砸蛋-金币数）
 * @property string $name 名称
 * @property string $photo_url 图片url
 * @property int $kind_type 0签到 1抽奖 2砸蛋
 * @property int $rate
 */
class SignDraw extends Model
{
    /**
     * The table associated with the model.
     */
    protected ?string $table = 'tb_sign_draw';

    /**
     * The attributes that are mass assignable.
     */
    protected array $fillable = [];

    /**
     * The attributes that should be cast to native types.
     */
    protected array $casts = ['id' => 'integer', 'type' => 'integer', 'gift_id' => 'integer', 'num' => 'integer', 'kind_type' => 'integer', 'rate' => 'integer'];

    /**
     * Note - 根据kind_type获取数据
     * DateTime 2024/8/12 12:15
     * User Admin
     * @param $kindType
     * @return mixed[]
     */
    public function getListByKindType($kindType)
    {
        // $sql="select * from {$this->table} where `kind_type` = ? ";
        $data = self::query()->where('kind_type', $kindType)->get();
        return $data->toArray();

    }

}
